import Axios from "axios";

export const getListData=(data)=>{
    return{
        type:'GETLISTDATA',
        payload:data
    }
}

export const fetchList = (params={page:1}) => {
    return dispatch => {
        const url = `http://129.211.11.178:3004/products?_page=${params.page}&_limit=8&_sort=id&_order=desc`;
        Axios({
            url: url,
            method: 'get'
        }).then(res => {
            //console.log(res.headers["x-total-count"]);
            //console.log(res.data);
            var obj={
                rows:res.data,//array
                total:res.headers["x-total-count"]
            }
            dispatch(getListData(obj));
        })
    }

}